 $(document).ready(function(){

	var pathname = window.location.pathname;
	if (pathname == "/organizational-chart" ) {	
		$('.fl-user-navigation-wrapper').css('display', 'none');
		$('.fl-content').css('width', '100%');
		$('.fl-main-container').css('background', 'url(images/themes/workspace.jpg)');
	};

	var urlPortal = '/application_portal';
	if (pathname == urlPortal ) {	
		$('.fl-content').css('width', '100%');
		$('.fl-user-navigation-wrapper').css('display', 'none');
	};

	var urlRequestview = '/request-view';
	if (pathname == urlRequestview ) {	
		$('.fl-content').css('width', '100%');
		$('.fl-user-navigation-wrapper').css('display', 'none');
	};

	

	var menuItem = $('.mainmenu li a');
	menuItem.removeClass('current');
	
	var matches = menuItem.filter(function () {
            return document.location.href.indexOf($(this).attr('href')) >= 0;
        });
	
	matches.addClass('current');


	$("body").hide();
	$("body").fadeIn("slow", "swing");
	

	$(".fl-user-onlineuser-avatar-wrapper").on('mouseenter', function(){
			$('div.fl-tooltip').stop(false, false).animate({
				opacity:1
			});	
	});	

	$(".fl-user-onlineuser-avatar-wrapper").on('mouseleave', function(){
			$('div.fl-tooltip').stop(false, false).animate({
				opacity:0
			});	
	});	

	$(".main-submenu").hide();
	$(".mainmenu > li:nth-child(4) > a").click(function(event){
		 event.preventDefault();
		 $(this).parent().find('.main-submenu').slideToggle('fast');		
	});

	
	/*$('.mainmenu li a').click(function(){
		$(this).find('i').removeClass('fa fa-chevron-circle-down');
		$(this).find('i').addClass('fa fa-chevron-circle-up');
	});*/
	

	$(".fl-main-content-wrapper").delay(1000).animate({
		left:0,
		opacity:1
	}, "fast");

	
	
	$(".fl-widget-starred-content-wrapper").on('mouseenter', function(){
		$(this).find('.fl-delete').stop(false, false).animate({
			opacity:1
		});
	});

	$(".fl-widget-starred-content-wrapper").on('mouseleave', function(){
		$(this).find('.fl-delete').stop(false, false).animate({
			opacity:0
		});
	});

	$('.fl-inbox-item').on('mouseenter', function(){
		$(this).find('.fl-delete').stop(false, false).animate({
			opacity:1
		});
	});

	$(".fl-inbox-item").on('mouseleave', function(){
		$(this).find('.fl-delete').stop(false, false).animate({
			opacity:0
		});
	});

	$('ul.notification li').on('mouseenter', function(){
		$(this).find('.fl-delete').stop(false, false).animate({
			opacity:1
		});
	});

	$("ul.notification li").on('mouseleave', function(){
		$(this).find('.fl-delete').stop(false, false).animate({
			opacity:0
		});
	});

	$(".fl-reply").click(function(){
		$(this).parents('.fl-message-body').eq(0).find('.fl-reply-box').fadeIn(500, function(){
			$(this).show();
		});

	});

	$('#fl-create-btn').click(function(){
		$('#fl-send-msg-form').fadeIn(1000, function(){
			$(this).show();
		});
		$('#fl-no-conversation-wrapper').hide();
	});

	$("#fl-action-btn").click(function(){
		$("#fl-action-option").slideToggle('fast');
	});

	$('#tabs li a:not(:first)').addClass('inactive');
	$('.tab-container').hide();
	$('.tab-container:first').show();

	    
	$('#tabs li a').click(function(){
	    var t = $(this).attr('id');
	  if($(this).hasClass('inactive')){ //this is the start of our condition 
	    $('#tabs li a').addClass('inactive');           
	    $(this).removeClass('inactive');
	    
	    $('.tab-container').hide();
	    $('#'+ t + 'C').fadeIn('slow');
	 }
	});

	$('#fl-save_personalInfo').click(function(){
		$('.uInfo_211, .eInfo_211').toggle();
		$('#fl-cancel_personalInfo').toggle();

		 $(this).val() == "Edit" ? Edit() : Save();
			
	});


		function Edit() {
		    $('#fl-save_personalInfo').val("Save");		   
		}

		function Save() {
		    $('#fl-save_personalInfo').val("Edit");		    
		}

	$('#fl-cancel_personalInfo').click(function(){
		$('.uInfo_211, .eInfo_211').toggle();
		$(this).hide();

		$('#fl-save_personalInfo').val() == "Edit" ? Edit() : Save();
	});

	$('#portal-app li').on('mouseenter', function(){
		$(this).find('.fl-app-btn').stop(false, false).animate({
			'margin-top':130,
			'border-width' : '20px',
			'border-color' : '#f00'
		}, 'fast');
	});

	$('#portal-app li').on('mouseleave', function(){
		$(this).find('.fl-app-btn').stop(false, false).animate({
			'margin-top':240
		}, 'slow');
	});

	$('.fl-search-wrapper form').find('input[type="text"]').focusin(function(){
		$('input[type="button"]').fadeIn(400, function(){
			$(this).show();
		})
	});	

	function toggleZoomScreen() {
	document.body.style.zoom="50%"
	} 

	$('#fl-showmenu').on('click', function(){		
		$('.fl-user-navigation-wrapper').toggle('slide');
	});

});

